package script.grammar.expression;

import script.grammar.symbol.Type;

public abstract class TernaryOperator implements Operator {
	@Override
	public int getArity() {
		return 3;
	}

	@Override
	public Type computeType(Type... operands) {
		if (operands.length != 3) {
			throw new IllegalArgumentException();
		}
		return computeTypeImpl(operands[0], operands[1], operands[2]);
	}
	
	protected abstract Type computeTypeImpl(Type o1, Type o2, Type o3);
}
